home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
keyb
/
togkey.zip
/
TOGKEY.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-01-08
|
6KB
|
294 lines
page 55,132
title TOGKEY -- Toggles the Insert, Caps, Num, Scroll, or Suspend (Hold) key.
;
FALSE EQU 0
TRUE EQU NOT FALSE
vn equ "1" ;version number
rn equ "0" ;revision number
;
data segment at 40h
;
foo db 16h dup(?)
;
kb_flag dw ? ;Keyboard Status
;
INS_STATE EQU 8000H
CAPS_STATE EQU 4000H
NUM_STATE EQU 2000H
SCROLL_STATE EQU 1000H
ALT_SHIFT EQU 0800H
CTL_SHIFT EQU 0400H
LEFT_SHIFT EQU 0200H
RIGHT_SHIFT EQU 0100H
;
kb_flage_1 db ? ;Second byte of Keyboard Status
;
INS_SHIFT EQU 80H
CAPS_SHIFT EQU 40H
NUM_SHIFT EQU 20H
SCROLL_SHIFT EQU 10H
HOLD_STATE EQU 08H
;
data ends
;
; MISCELLANEOUS EQUATES
;
CR EQU 0dh
LF EQU 0ah
eom equ 0 ;End of string char (did you think I was going to
;use '$' ?!!!)
DosCall EQU 21h ;INTERUPT NUMBER FOR DOS CALL
;
prognam segment public
;
;
assume cs:prognam,ds:prognam,ss:prognam
org 80h
psiz db ?
pstng db ?
org 100h
;
start: jmp intial
db cr,lf,"TOGKEY ver:",vn,".",rn
db cr,lf,"Copyright 1988 by Timothy M. Pozar"
db cr,lf,"Please don't rip me off!!",cr,lf,1ah ;ends with a ^Z
db 57h,08h,20h,32h,20h ;ser
;
intial: mov ax,cs
mov ds,ax
mov ss,ax
mov sp,offset stack
;
begin: ;beginning of programme
mov al,psiz ;how many char are on the command line
mov switch_num,al
cmp al,0
jz help ;if there is none, display help msg
cmp al,1
jnz nohelp ;if there is just one, display help msg
;else skip over and start parsing
help:
mov dx,offset signon_msg
call pstring
jmp done
nohelp:
sub cx,cx
mov cl,switch_num
mov si,offset pstng ;start of command string
cld
;
lp1:
lodsb
cmp al,switch_char1
jz tswtch
cmp al,switch_char2
jz tswtch
jmp lpend
tswtch: push ax
mov ax,TRUE
mov switch_rcv,ax
pop ax
dec cx ;test for what switch char is there
lodsb
;
tog_ins1:
cmp al,"i"
jz tog_ins2
cmp al,"I"
jnz tog_cap1
tog_ins2: ;set insert flag to true
mov ax,TRUE
mov insert_flg,ax
jmp lpend
;
tog_cap1:
cmp al,"c" ;set caps flag to true
jz tog_cap2
cmp al,"C"
jnz tog_num1
tog_cap2:
mov ax,TRUE
mov caps_flg,ax
jmp lpend
;
tog_num1:
cmp al,"n" ;set numlock flag to true
jz tog_num2
cmp al,"N"
jnz tog_scroll1
tog_num2:
mov ax,TRUE
mov num_flg,ax
jmp lpend
;
tog_scroll1:
cmp al,"s" ;set scroll flag to true
jz tog_scroll2
cmp al,"S"
jnz defalt
tog_scroll2:
mov ax,TRUE
mov scroll_flg,ax
jmp lpend
defalt:
;Did not reconize this char as a valid command.
push ax
mov dx,offset duh_msg
call pstring
pop ax
call pchar
mov al,'.'
call pchar
jmp done
lpend: loop lp1
;
lpfin:
mov ax,switch_rcv ;did we get a valid switch char some
cmp ax,TRUE ;where in there?
jz main
mov dx,offset no_swtch_msg ;if not, bomb out
call pstring
jmp done
;
; M A I N
;
main:
;
flip_cap:
mov ax,caps_flg
cmp ax,true
jnz flip_ins
mov dx,offset capsmsg
call pstring
mov cx,CAPS_STATE
call modkeyb
;
flip_ins:
mov ax,insert_flg
cmp ax,true
jnz flip_num
mov dx,offset insmsg
call pstring
mov cx,INS_STATE
call modkeyb
;
flip_num:
mov ax,num_flg
cmp ax,true
jnz flip_scroll
mov dx,offset nummsg
call pstring
mov cx,NUM_STATE
call modkeyb
;
flip_scroll:
mov ax,scroll_flg
cmp ax,true
jnz done
mov dx,offset scrollmsg
call pstring
mov cx,SCROLL_STATE
call modkeyb
;
done:
mov dx,offset newline
call pstring
mov ah,4ch
int DosCall ; That's all Folks !
;
modkeyb proc near
push ds
mov ax,data
mov ds,ax
mov bx,offset kb_flag
xor [bx],cx
pop ds
ret
modkeyb endp
pstring proc near
;SAMPLE CALL TO PSTRING
;mov dx,offset anounc ;point to address of message "anounc"
;call pstring ;display anounc
;
mov bx,dx
pmore: mov al,[bx]
cmp al,eom
jz pfin
call pchar
inc bx
jmp pmore
pfin: ret
;
pstring endp
;
pchar proc near
;sends one char to the console
mov ah,2
mov dl,al
int DosCall
ret
;
pchar endp
;ZEE DATA AREA --
;
;Messages
;
no_swtch_msg db cr,lf," Did not find the current switch character on the command"
db cr,lf," line. Please use either '/' or '-'."
db eom
duh_msg db cr,lf," Did not reconize the command line switch character "
db eom
newline db cr,lf,eom
capsmsg db cr,lf," Changeing state of the CapsLock key.",eom
insmsg db cr,lf," Changeing state of the Insert key.",eom
nummsg db cr,lf," Changeing state of the NumLock key.",eom
scrollmsg db cr,lf," Changeing state of the ScrollLock key.",eom
;
signon_msg db cr,lf,"TOGKEY ver:",vn,".",rn," 8.Jan.88"
db cr,lf," Copyright (c)1988 T. M. Pozar"
db cr,lf," Voice (415) 788-2022 / Data (415) 391-2657"
db cr,lf," Use limited to private (non-commercial) only. Commercial use, by the "
db cr,lf," written permission of the author only."
db cr,lf," "
db cr,lf," TOGKEY will toggle the state of a paticular key, such as the CapsLock, or"
db cr,lf," Insert keys. In order to toggle those keys the associated command line"
db cr,lf," switch must be specified. For example:"
db cr,lf," A>togkey -N -C <return>"
db cr,lf," "
db cr,lf," In this example we have told the programme to toggle the state of the"
db cr,lf," NumLock and CapsLock keys. (See below for the switch settings.) This"
db cr,lf," will not change the lights on the keyboard, it will only change the state"
db cr,lf," table in memory."
db cr,lf," "
db cr,lf,"Switch Settings... (Should be preceded by '-' or '/')"
db cr,lf," C = CapsShift (or CapsLock)"
db cr,lf," I = Insert"
db cr,lf," N = NumShift (or NumLock)"
db cr,lf," S = ScrollShift"
db eom
;
;
;
switch_num db 0
switch_char1 db "-"
switch_char2 db "/"
switch_rcv dw FALSE ;TRUE = got a valid switch char on command line
caps_flg dw FALSE ;TRUE = toggle caps lock state
insert_flg dw FALSE ;TRUE = toggle insert state
num_flg dw FALSE ;TRUE = toggle num lock state
scroll_flg dw FALSE ;TRUE = toggle scroll lock state
;
db 10 dup ('stack ') ;room for stack
stack label byte ;top of stack
prognam ends
end start